package com.cuckoo.mall.thus.order.addorder;


import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.TextView;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.alibaba.android.arouter.launcher.ARouter;
import com.bgn.baseframe.base.BaseActivity;
import com.bgn.baseframe.base.MVPBaseActivity;
import com.bgn.baseframe.utils.BaseStringUtil;
import com.bgn.baseframe.utils.evenbus.MainEvent;
import com.bgn.baseframe.utils.jsontool.GsonUtil;
import com.cuckoo.mall.R;
import com.cuckoo.mall.javabean.OrderResult;

import org.greenrobot.eventbus.EventBus;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * MVPPlugin
 * 邮箱 784787081@qq.com
 */
@Route(path = "/mall/addOrderSucceedActivity", group = "mall")
public class AddOrderSucceedActivity extends BaseActivity {


    @BindView(R.id.tv_order_num)
    TextView tvOrderNum;
    @BindView(R.id.tv_price)
    TextView tvPrice;
    @BindView(R.id.tv_go_detail)
    TextView tvGoDetail;
    @BindView(R.id.tv_go_back)
    TextView tvGoBack;
    /*数据*/
    private OrderResult result;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setIsLoadTitleBar(false);
        setContentView(R.layout.activity_add_order_succeed);
        ButterKnife.bind(this);
        initView();
    }

    private void initView() {
        String dataString = getIntent().getStringExtra(DATASTRING);
        result = GsonUtil.fromJson(dataString, OrderResult.class);
        tvPrice.setText(result.getCurrency() + " " + BaseStringUtil.getPrioceFormatString(result.getPay_money()));
        tvOrderNum.setText(result.getOrder_number());
    }

    @OnClick({R.id.tv_go_detail, R.id.tv_go_back})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.tv_go_detail:
                ARouter.getInstance().build("/mall/mainActivity").navigation();
                ARouter.getInstance().build("/mall/orderdetailActivity").withString("order_number", result.getOrder_number()).navigation();
                break;
            case R.id.tv_go_back:
//                EventBus.getDefault().post(new MainEvent(MainEvent.HIDE_CART_WHEN_LOGIN_OUT));
//                ARouter.getInstance().build("/mall/mainActivity").navigation();
                ARouter.getInstance().build("/mall/mainActivity").withString("action", "home").navigation();
                break;
        }
    }

    @Override
    public void onBackPressed() {

    }
}
